//
//  YBSecCell.m
//  OurTourism
//
//  Created by 孟镇 on 15/11/26.
//  Copyright © 2015年 Devil_Coming. All rights reserved.
//

#import "YBSecCell.h"


@interface YBSecCell ()
@property (nonatomic, strong)UIImageView *coverImg;


@end


@implementation YBSecCell
#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.coverImg = [[UIImageView alloc]init];
        [self.contentView addSubview:self.coverImg];
        self.coverImg.contentMode = UIViewContentModeScaleAspectFill;
        self.coverImg.clipsToBounds = YES;

        self.titleLable = [[UILabel alloc]init];
        self.titleLable.numberOfLines = 2;
        [self.contentView addSubview:self.titleLable];
        self.titleLable.textColor = [UIColor darkGrayColor];
        self.titleLable.font = [UIFont systemFontOfSize:12];

        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    
    [self.coverImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(0);
        make.top.mas_equalTo(self.contentView).offset(0);
        make.size.mas_equalTo(CGSizeMake(layoutAttributes.size.width, 150));
    }];
    
    [self.titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(10);
        make.bottom.mas_equalTo(self.coverImg).offset(40);
        make.size.mas_equalTo(CGSizeMake(layoutAttributes.size.width - 20, 30));
    }];
    
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    self.titleLable.textColor = [UIColor darkGrayColor];
    self.coverImg.backgroundColor = [UIColor whiteColor];
    
}


#pragma mark - 首页故事赋值
- (void)setRecommendModel:(YBDestinationModel *)recommendModel
{
    
    [self.coverImg sd_setImageWithURL:[NSURL URLWithString:recommendModel.index_cover] ];
    self.titleLable.text = recommendModel.index_title;
}
#pragma mark - 全部页赋值
- (void)setStoryAllModel:(YBDestinationModel *)storyAllModel
{
    
    [self.coverImg sd_setImageWithURL:[NSURL URLWithString:storyAllModel.index_cover] ];
    self.titleLable.text = storyAllModel.index_title;
   
}



@end
